<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>订单信息</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport"
			content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
		<link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css" media="all">
		<link rel="stylesheet" href="../../../layuiadmin/style/admin.css" media="all">
		<link rel="stylesheet" href="../../../css/common.css" media="all">
		<style>
			.list-tb-div td .tDiv {
				padding: 0px;
				text-align: center;
				word-break: break-all;
			}

			.tpinfo {
				min-height: 100px;
				border-bottom: 1px solid #ececec;
			}

			.td-product img {
				border: 1px solid #efefef;
				padding: 1px;
			}

			.list-tb-div td .tDiv {
				padding: 10px;
				text-align: center;
				word-break: break-all;
			}

			.list-tb-div td .tDiv.left {
				padding: 10px;
				text-align: left;
				word-break: break-all;
			}

			.list-tb-div .td-product .product-info {
				padding-left: 90px;
				text-align: left;
				margin-top: 20px;
			}

			blockquote,
			body,
			button,
			dd,
			div,
			dl,
			dt,
			form,
			h1,
			h2,
			h3,
			h4,
			h5,
			h6,
			input,
			li,
			ol,
			p,
			pre,
			td,
			textarea,
			th,
			ul {
				margin: 0;
				padding: 0;
				-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
			}

			.list-tb-div table {
				margin-bottom: 5px;
				font-size: 12.5px;
			}

			.list-div table {
				width: 120%;
			}

			table {
				border-collapse: collapse;
				border-spacing: 0;
			}

			.list-tb-div .td-product .img {
				width: 80px;
				height: 80px;
			}

			.list-tb-div .tr-order-sn .tDiv {
				text-align: left;
				padding: 0;
			}

			.list-tb-div td .tDiv {
				padding: 10px;
				text-align: center;
				word-break: break-all;
			}

			.list-tb-div td .ml10 {
				padding-left: 5px;
			}

			.list-tb-div td .ml10 .words {
				margin-left: 10px;
				margin-right: 10px;
				line-height: 28px;
			}

			.list-tb-div .tr-order-sn .tDiv.center {
				text-align: center;
				padding: 0;
			}

			.layui-table td,
			.layui-table th {
				position: relative;
				padding: 9px 15px;
				min-height: 20px;
				line-height: 20px;
				font-size: 14px;
			}
		</style>
		<style type="text/css">
			td .layui-table-cell {
				text-align: center;
				height: 100px;
				white-space: normal;
			}

			.layui-table img,
			.layui-table video {
				width: 50px;
				max-width: 60px;
			}

			td .layui-table-cell {
				text- align: center;
				height: auto;
				white-space: normal;
			}

			.tDiv {
				font-size: 10px;
				line-height: 15px;
			}

			.tDiv-price {
				font-size: 15px;
				line-height: 18px;
			}
		</style>

	</head>

	<body>
		<div class="layui-fluid">
			<div class="layui-row layui-col-space15">
				<div class="layui-col-md12">
					<div class="layui-card">
						<!--导入订单-->
						<!--<div class="layui-card-header">
							<button type="button" class="layui-btn" id="import_order" data-method="import">批量导入订单</button>
						</div>-->
						<div class="layui-card-header">
							<button type="button" class="layui-btn" id="import_order"
								data-method="export">批量导出订单</button>
							<button type="button" class="layui-btn layui-btn-normal" id="batchDesignate"
								data-method="batchDesignate">批量派单</button>
							<button type="button" class="layui-btn layui-btn-warm" id="batchDelete"
								data-method="batchDelete">批量删除已取消</button>
						</div>
						<!--<div class="layui-card-header">
							<span class="marign_right10">订单：</span>
							<button class="layui-btn layui-btn-danger layui-btn-sm" id="del">删除</button>
						</div>-->
						<div class="layui-tab layui-tab-brief" lay-filter="changetab">
							<ul class="layui-tab-title" id="view_ul"></ul>
							<div class="layui-card-body">
								<!-- 搜索 -->
								<form class="layui-form search" id="form" onsubmit="return false" action="##">

									<div class="layui-inline search_inline">
										<label class="layui-form-label">订单编号：</label>
										<div class="layui-input-inline">
											<input class="layui-input" lay-verify="" name="orderid" placeholder="订单编号"
												autocomplete="off">
										</div>
									</div>
									<div class="layui-inline search_inline">
										<label class="layui-form-label">用户编号：</label>
										<div class="layui-input-inline">
											<input class="layui-input" lay-verify="userid" name="userid"
												placeholder="用户编号" autocomplete="off">
										</div>
									</div>
									<div class="layui-inline search_inline">
										<label class="layui-form-label">会员编号：</label>
										<div class="layui-input-inline">
											<input class="layui-input" lay-verify="member_id" name="member_id"
												placeholder="会员编号" autocomplete="off">
										</div>
									</div>
									<div class="layui-inline search_inline">
										<label class="layui-form-label">姓名/手机号：</label>
										<div class="layui-input-inline">
											<input class="layui-input" lay-verify="keyword" placeholder="姓名、手机号"
												name="keyword" autocomplete="off">
										</div>
									</div>
									<div class="layui-inline search_inline">
										<label class="layui-form-label">地址：</label>
										<div class="layui-input-inline">
											<input class="layui-input" lay-verify="address" placeholder="地址"
												name="address" autocomplete="off">
										</div>
									</div>
									<div class="layui-inline">
										<label class="layui-form-label">日期时间类型</label>
										<div class="layui-input-block">
											<select name="time" class=" " lay-filter="time">
												<option value="">全部</option>
												<option value="addtime">创建订单时间</option>
												<option value="pay_time">付款时间</option>
												<option value="edittime">服务时间</option>
												<option value="finish_time">订单完成时间</option>
											</select>
										</div>
									</div>

									<div class="layui-inline">
										<label class="layui-form-label">日期时间范围</label>
										<div class="layui-input-block">
											<input type="text" class="layui-input" id="test10" placeholder=" - "
												name="range_date">
										</div>
									</div>
									<button class="layui-btn search_inline" lay-submit="" lay-filter="search"
										data-type="reload">搜索</button>
									<button class="layui-btn layui-btn-primary search_inline" type="reset">重置</button>
								</form>

								<!-- 修改前的表格 -->
								<table class="layui-hide " id="test-table-operate" lay-filter="test-table-operate">
								</table>

								<script type="text/html" id="zizeng">
								{{d.LAY_TABLE_INDEX+1}}
								</script>
								<script type="text/html" id="test-table-operate-barDemo">
									<!--{{# if(d.status < 70 ){ }}
										<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="choose_team">更换社区</a>
									{{# } }}-->

								<a class="layui-btn layui-btn-xs" lay-event="orderdetail">订单详情</a>
								<!--删除订单   状态取消-->
								{{# if(d.status ===0 ){ }}
									<a class="layui-btn layui-btn-xs layui-btn-warm " lay-event="order_delete">删除订单</a>
									{{# } }}
										<!--未付款之前可以取消订单 -->
											{{# if(d.status >0 ){ }}
											<a class="layui-btn layui-btn-xs layui-btn-danger "
												lay-event="order_cancel">取消订单</a>
											{{# } }}
												<!--付款之后派单-->
												{{# if(d.status == 30 ){ }}
													<a class="layui-btn layui-btn-normal layui-btn-xs"
														lay-event="designate">派单</a>
													{{# } }}



								</script>
								<!--现金支付-->
								<script type="text/html" id="test-table-operate-pay">
									<div class="tDiv left">
										<font style="color: #000;">{{pay_status_show(1, d.status_pay)}}</font><br> {{# if(d.status_pay == 10 ){ }}
											<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="pay_money">现金支付</a>
											{{# } }}

									</div>
								</script>

								<!--佣金详情-->
								<script type="text/html" id="test-table-operate-fee">

								{{# layui.each(d.orders_fee,function(index,o){ }}

									{{# if(d.names[index]){  }}
										<div class="tDiv" style="">
											{{# if(d.names[index].master){ }}
												师傅收入： {{d.names[index].master ?d.names[index].master:''}}
												<span class="line-text"> {{o.recommend_fee?o.recommend_fee:''}}</span>
												<br />
												{{# } }}
													{{# if(d.names[index].parent){ }}
														上级收入： {{d.names[index].parent?d.names[index].parent:''}}
														<span class="line-text"> {{o.recommend_fee}}</span>
														<br />
														{{# } }}
															{{# if(d.names[index].super){ }}
																上上级收入： {{d.names[index].super?d.names[index].super:''}}
																<span class="line-text"> {{o.recommend_fee}}</span>
																{{# } }}

										</div>
										{{# }}}
											{{# })}}
								</script>

								<!--商品详情-->
								<script type="text/html" id="test-table-operate-goods">
									<font style="color: #000;">订单编号：{{d.orderid?d.orderid:''}}</font><br>
									{{# layui.each(d.orders_sub,function(index,o){ }} {{# if(o.goods_image_url){ }}
											<div class="tDiv relative     " style="text-align: left;">
												<div class="img" style="display: inline-block;vertical-align: top;">
													<img width="70" src={{o.goods_image_url}} alt="">
												</div>
												<div class="name mb5" style="display: inline-block;vertical-align: top;">
													商品编号:{{o.skuid}} ,<br /> 商品名称:{{o.skuname}} ,<br /> 规格参数:{{o.specparam}},
												</div>
											</div>
											{{# }}} {{# })}}
								</script>

								<!--会员信息-->
								<script type="text/html" id="test-table-operate-member">
									<div class="tDiv left" style="text-align: left;">
										<font style="color: #000;">会员编号：{{d.memberid?d.memberid:''}}</font><br>
										<font style="color: #000;">用户编号：{{d.userid?d.userid:''}}</font><br>
										<font style="color: #000;">店铺编号：{{d.agentshopid?d.agentshopid:''}}</font><br>
										<font style="color: #000;">店铺名称：{{d.shopname?d.shopname:''}}</font><br>
										<font style="color: #000;">用户姓名：{{d.name?d.name:''}}</font><br>
										<font style="color: #000;">用户手机：{{d.membermobile?d.membermobile:''}}</font><br>
									</div>
								</script>
								<script type="text/html" id="test-table-operate-order_detail">
									<div class="tDiv left" style="text-align: left;">
										<font style="color: #000;">运费：{{d.price_waybill?d.price_waybill:''}}</font><br>
										<font style="color: #000;">订单金额：{{d.amount?d.amount:''}}</font><br>
										<font style="color: #000;">抵扣金额：{{d.fee?d.fee:''}}</font><br>
										<font style="color: #000;">使用积分：{{d.fee_score?d.fee_score:''}}</font><br>
										<font style="color: #000;">使用积分比例：{{String(d.fee_score_scale)?d.fee_score_scale:''}}</font><br>
										<font style="color: #000;">使用红包：{{d.fee_packet?d.fee_packet:''}}</font><br>
										<font style="color: #000;">专属折扣：{{d.discount?d.discount:''}}</font><br>
										<font style="color: #000;">推荐人返佣：{{ d.recommend_orders_fee ? d.recommend_orders_fee   : ''}}</font><br>
										<font style="color: #000;">商品数量：{{d.quantity?d.quantity:''}}</font><br>
										<font style="color: #000;">支付金额：
											<span id="" class="importane">
												{{d.pay_price?d.pay_price:''}}
											</span>
										</font><br>
										<font style="color: #000;">
											付款方式：{{d.payment ? '<span class="text_red_color">' + payment_show(1, d.payment) + '</span>' : '未付款'}}
										</font>
									</div>
								</script>
								<!--收货人信息-->
								<script type="text/html" id="test-table-operate-consignee">
									<div class="tDiv" style="text-align: left;">
										<div>
											姓名：{{d.consignee?d.consignee:''}}
										</div>
										<div>
											电话：{{d.mobile?d.mobile:''}} </div>
										<div>
											地址：
											<font>{{ d.areaname?d.areaname :''}} </font> <br>
											<font class="line-text"> {{ d.address?d.address :''}} </font>
										</div>
									</div>
								</script>

								<!--客户备注信息-->
								<script type="text/html" id="test-table-operate-notes">
									<div>
										<font style="color: red; font-size: 15px;">{{ d.notes?d.notes :''}} </font>
									</div>
									</div>
								</script>
								<!--社区信息-->
								<script type="text/html" id="test-table-operate-member_team">
									<div class="tDiv" style="text-align: left;">
										<div>
											社区编号：{{d.teamid?d.teamid:''}}
										</div>
										<div>
											团长名称：{{d.team_name?d.team_name:''}} </div>
										<div>
											社区名称：
											<font>{{ d.community_name?d.community_name :''}} </font>
										</div>
									</div>
								</script>

								<!--付款信息-->
								<script type="text/html" id="test-table-operate-member_price">
									<div class="tDiv" style="text-align: left;">
										<div>
											共计：{{d.pay_price?d.pay_price:''}}
										</div>
										<div>
											红包抵扣：{{d.fee_packet?d.fee_packet:''}}
										</div>
										<div>
											付款方式：
											<font>{{ d.payment ?payment_show(1, d.payment) :'未付款'}} </font>
										</div>
										<div>
											分期：{{ d.fq ? d.fq : ''}}
										</div>
									</div>
								</script>

								<!--订单记录时间-->
								<script type="text/html" id="test-table-operate-member_time">
									<div class="tDiv" style="text-align: left;">
										<div>
											下单时间：{{d.addtime?d.addtime:''}}
										</div>
										<div>
											付款时间：{{d.pay_time?d.pay_time:''}}
										</div>
										<div>
											服务时间：{{d.serve_dates?d.serve_dates+" "+d.server_times:''}}
										</div>
										<div>
											完成时间：{{ d.finish_time?d.finish_time :''}}
										</div>
									</div>
								</script>

								<!--备注-->
								<script type="text/html" id="mark">
									<div class="tDiv notes" style="text-align: left;color: red;font-size: 14px;" value="{{d.id}}"
										order="{{d.orderid}}" data-method="notes_edit">
										{{d.mark?d.mark:'点击此处添加备注'}}
									</div>
								</script>

							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<!-- 取消订单 选择退款类型 -->
		<div id="modelone" style="display: none;">
			<form class="layui-form" action="" style="margin-top: 30px;">
				<div class="layui-form-item">
					<label class="layui-form-label">退款类型</label>
					<div class="layui-input-block">
					  <input type="radio" name="refund" value="1" title="线下退" checked>
					  <input type="radio" name="refund" value="2" title="原路退" >
					</div>
				</div>
				<div class="layui-form-item" style="text-align: center;">
				    <button class="layui-btn" lay-submit lay-filter="formDemo">确定</button>
				</div>
			</form>
		</div>
		<script type="text/html" id="demo_ul">
			<li class="layui-this" lay-id=''>全部</li>
			{{# layui.each(d, function(index, item){ }}
				<li class="" lay-id='{{ item.value }}'>{{ item.name }}</li>
				{{# }); }}
		</script>
     
		<script src="../../../js/jquery.min.js"></script>
		<script src="../../../layuiadmin/layui/layui.js"></script>
		<script src="../../../js/common.js"></script>
		<script>
			layui.config({
				base: '../../../layuiadmin/' //静态资源所在路径
			}).extend({
				index: 'lib/index' //主入口模块
			}).use(['index', 'table', 'form', 'layer', 'laypage', 'element', 'laydate'], function() {
				var table = layui.table,
					$ = layui.$,
					form = layui.form,
					laytpl = layui.laytpl,
					laypage = layui.laypage,
					element = layui.element,
					laydate = layui.laydate,
					admin = layui.admin;

				var _data = {
					status: '',
					orderid: '',
					keyword: '',
					type: 1,
				}
				var _time = {

				}
				service_order_show("option");

				card_type()
				initdata()
				//日期时间范围
				laydate.render({
					elem: '#test10',
					type: 'date',
					range: true,
					done: function(value, date) {
						var s_time = value.split(' - ')[0]+' 00:00:00'
						var e_time = value.split(' - ')[1]+' 23:59:59'
						var time = $('select[name=time]').val();
						console.log(time)
						_time = {};
						_data = {};
						switch (time) {
							case 'addtime':
								_time.add_stime = s_time;
								_time.add_etime = e_time;
								break;
							case 'edittime':
								_time.edit_stime = s_time;
								_time.edit_etime = e_time;
								break;
							case 'pay_time':
								_time.pay_stime = s_time;
								_time.pay_etime = e_time;
								break;
							case 'finish_time':
								_time.fin_stime = s_time;
								_time.fin_etime = e_time;
								break;
							default:
								_time.pay_stime = s_time;
								_time.pay_etime = e_time;
								break;
						}

					}
				});

				element.on('tab(changetab)', function(elem) {
					status = this.getAttribute('lay-id');
					_data.status = status;
					statusCheck(status)
					initdata();
				});
				form.on('select(time)', function() {
					$("input[name=range_date]").val('')
					_time = {};
				})
				window.choosedata = function() {
					layer.open({
						type: 2,
						title: '选择',
						shadeClose: false,
						shade: 0.5,
						maxmin: true, //开启最大化最小化按钮
						area: ['70%', '70%'],
						content: 'model/list.html',
						end: function() {},
						success: function() {}
					});
				}

				function statusCheck(status) {
					$('#batchDelete').hide();
					$('#batchDesignate').hide()
					if (status == 30) {
						$('#batchDesignate').show()
					} else if (status == "0") {
						$('#batchDelete').show()
					}
				}

				function initdata() {
					table.render({
						elem: '#test-table-operate',
						url: server.server_order_query,
						height: 'full-115',
						cellMinWidth: cellMinWidth,
						limit: limit,
						limits: limits,
						cols: [
							[{
									width: 70,
									type: 'numbers',
									title: '序号',
								}, {
									type: 'checkbox',
								}, {
									width: 180,
									align: 'center',
									toolbar: '#test-table-operate-barDemo',
									title: '操作',
								}, {
									field: 'status', //member_type_show
									title: '订单状态',
									width: 130,
									templet: function(d) {
										//return service_order_show(1, d.status) <a style="color: red;"></a>
										return '<a style="color:' + service_order_color_show(1., d
												.status) + ';">' + service_order_show(1, d.status) +
											'</a>'
									}
								}, {
									width: 180,
									field: 'mark',
									title: '备注',
									toolbar: '#mark',
								}, {
									width: 180,
									field: 'memberid',
									title: '会员编号',
									toolbar: '#test-table-operate-member',
									sort: true
								}, {
									width: 180,
									title: '收件人信息',
									field: 'consignee',
									templet: '#test-table-operate-consignee'
								}, {
									field: 'type', //member_type_show
									title: '订单信息',
									width: 400,
									templet: '#test-table-operate-goods'
								}, {
									width: 180,
									field: 'consignee',
									title: '支付信息',
									toolbar: '#test-table-operate-order_detail',
									sort: true
								}, {
									field: 'notes', //member_type_show
									title: '客户备注',
									width: 180,
									templet: '#test-table-operate-notes'
								}, {
									field: 'order_photos',
									width: 120,
									title: '客户备注图片',
									templet: function(d) {
										return d.order_photos ?
											'<a class="text_blue_color" href="javascript:;" lay-event="image">查看</a>' :
											''
									}
								}, {
									//field: 'server_time', //member_type_show
									title: '服务时间',
									width: 220,
									templet: '#test-table-operate-member_time',
									field: 'serve_dates',
									sort: true
								}, {
									//field: 'pay_price',
									width: 180,
									title: '共计($)',
									toolbar: '#test-table-operate-member_price',
								}, {
									width: 180,
									title: '确认完成签名',
									//field: 'sign_img',
									templet: function(d) {
										return d.sign_img ?
											'<a class="text_blue_color" href="javascript:;" lay-event="goods_gallery_urls">查看</a>' :
											''
									}
								},
								{
									width: 180,
									title: '佣金信息',
									templet: '#test-table-operate-fee',
								},
								/* {
																	field: 'client',
																	title: '客户端',
																	templet: function(d) {
																		var type = d.client;
																		if(type) {
																			var type_leng = type.split(',');
																			var type_show = ''
																			for(var i = 0; i < type_leng.length; i++) {
																				type_show += icon_type_show(1, type_leng[i]) + ','
																			}
																			return type_show
																		} else {
																			return ''
																		}
																	}
																},*/
								{
									field: 'addtime',
									title: '创建时间',
									templet: function(d) {
										return d.addtime ? d.addtime : ''
									},
									sort: true
								}, {
									field: 'edit_by',
									title: '更新人',
									templet: function(d) {
										return d.edit_by ? d.edit_by : ''
									}
								}, {
									field: 'edittime',
									title: '更新时间',
									templet: function(d) {
										return d.edittime ? d.edittime : ''
									}
								}
							]
						],
						//toolbar: 'default',
						//defaultToolbar: ['filter', 'print', 'exports']
						//defaultToolbar: ['exports'],
						page: true,
						where: _data,
						request: {
							pageName: 'page',
							limitName: 'size',
						},
						parseData: function(res) { //将原始数据解析成 table 组件所规定的数据
							return {
								"code": res.code, //解析接口状态
								"msg": res.msg, //解析提示文本
								"count": res.server_order.pager.total, //解析数据长度
								"data": res.server_order.data //解析数据列表
							};
						},
						done: function() {}
					});

				}

				//监听搜索
				form.verify({
					memberid: function(value, item) { //value：表单的值、item：表单的DOM对象
						if (!value) {
							return '姓名不能为空';
						}
					}
				});

				form.on('select(service_order)', function(data) {
					_data.status = data.value;
					initdata();
				});

				//监听搜索
				form.on('submit(search)', function(data) {
					loading()
					Object.assign(_data, _time)
					Object.assign(_data, data.field)
					initdata();
					closeloading()
					return false;
				});

				$("button[type=reset]").on("click", function() {
					_data = {
						type: 1
					}
					_time = {};
					loading()
					initdata();
					document.getElementById("form").reset();
					closeloading()
				});
				table.on('toolbar(test-table-operate)', function(obj) {
					debugger
					var checkStatus = table.checkStatus(obj.config.id),
						data = checkStatus.data; //获取选中的数据
					switch (obj.event) {
						case 'add':

							break;
						case 'update':
							break;
						case 'delete':
							if (data.length === 0) {
								layer.msg('请选择一行');
							} else {
								layer.open({
									content: '确定要删除这些选中' + checkStatus.data.length +
										'条订单吗？删除订单的同时会清除所有订单有关的明细,请谨慎操作!',
									btn: ['是', '否'],
									yes: function(index, layero) {
										var id = ''
										for (var i = 0; i < checkStatus.data.length; i++) {
											id += checkStatus.data[i].id + ','
										}

										$.get(server.server_order_delete, {
											'id': id
										}, function(res) {
											if (res.code == 0) {
												layer.msg('删除成功')
											} else {
												layer.msg(res.msg)
											}
										})
										location.reload()
										layer.closeAll();
									},
									no: function(index, layero) {
										layer.closeAll();
									}
								})

							}
							break;
					};
				});
				var cancel_data;
				//监听工具条
				table.on('tool(test-table-operate)', function(obj) {
					var data = obj.data;
					if (obj.event === 'edit') {
						layer.open({
							type: 2,
							title: '修改',
							shadeClose: false,
							shade: 0.5,
							maxmin: true, //开启最大化最小化按钮
							area: ['900px', '90%'],
							content: 'model/test_edit.html?orderid=' + data.orderid,
							end: function() {
								location.reload()

							}
						});
					} else if (obj.event === 'orderdetail') {

						location = 'model/order_details.html?orderid=' + data.orderid + '&from=list'
					} else if (obj.event === 'designate') {
						layer.open({
							type: 2,
							title: '派单',
							shadeClose: false,
							shade: 0.5,
							area: ['40%', '90%'],
							content: 'model/order_designate.html?orderid=' + data.orderid,
							success: function(layero, index) {
								var iframe = window['layui-layer-iframe' + index]
								iframe.child({
									'consignee': data.consignee,
									'memberid': data.memberid
								}, index)
							},
							end: function() {
								table.reload()
								//location.reload()
							}
						});
					} else if (obj.event === 'pay_money') {
						layer.open({
							type: 2,
							title: '现金支付',
							shadeClose: false,
							shade: 0.5,
							area: ['90%', '90%'],
							content: 'model/order_pay_money.html?orderid=' + data.orderid,
							end: function() {
								location.reload()
							}
						});
					} else if (obj.event === 'order_cancel') {
						if(data.status=='10'){
							var lock = false
							layer.confirm('确定要取消这个订单吗？', function() {
								if (!lock) {
									lock = true
									$.ajax({
										url: server.server_order_cancel,
										type: 'post',
										dataType: 'json',
										data: "orderid=" + data.orderid,
										success: function(data) {
											if (data.code == '0') {
												layer.msg('操作成功');
												initdata()
											} else {
												layer.msg('操作失败');
											}
										},
										'error': function() {
											layer.msg('系统错误');
										}
									})
								}
							});
						}else if(data.status>10){
							cancel_data=data
							layer.open({
								type: 1,
								title: '取消订单',
								area: ['300px', '200px'],
							    content: $('#modelone')
							});
						}
						
					} else if (obj.event === 'goods_gallery_urls') {
						if (data.sign_img) {
							var imgarr = data.sign_img.split(',');
							console.log(imgarr)
						}
						var img_data = {
							"data": [{
								"src": imgarr[0]
							}]
						}
						for (var i = 1; i < imgarr.length; i++) {
							img_data.data.push({
								"src": imgarr[i]
							})
						}

						layer.photos({
							photos: img_data,
							anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机
						});
					} else if (obj.event === 'order_delete') {
						var lock = false
						layer.confirm('确定要删除这个订单吗？', function() {
							if (!lock) {
								lock = true
								$.ajax({
									url: server.server_order_delete,
									type: 'post',
									dataType: 'json',
									data: "orderid=" + data.orderid,
									success: function(data) {
										if (data.code == '0') {
											layer.msg('操作成功');
											initdata()
										} else {
											layer.msg('操作失败');
										}
									},
									'error': function() {
										layer.msg('系统错误');
									}
								})
							}
						});
					} else if (obj.event === 'image') {
						if (data.order_photos) {
							var imgarr = data.order_photos.split(',');
						}
						var img_data = {
							"data": [{
								"src": imgarr[0]
							}]
						}
						for (var i = 1; i < imgarr.length; i++) {
							img_data.data.push({
								"src": imgarr[i]
							})
						}

						layer.photos({
							photos: img_data,
							anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机
						});
					}
				});

				var active = {
					notice: function(orderid) {
						console.log(orderid)
						layer.open({
							type: 2,
							title: '派单',
							shadeClose: false,
							shade: 0.5,
							area: ['90%', '90%'],
							content: 'model/order_designate.html?type=1&orderid=' + orderid,
							end: function() {
								table.reload()
								//location.reload()
							}
						});
					},
					import: function() {
						layer.open({
							type: 2,
							title: '导入',
							shadeClose: false,
							shade: 0.5,
							area: ['90%', '90%'],
							content: 'model/order_import.html?',
							end: function() {
								location.reload()
							}
						});
					},
					export: function() {
						//导出
						layer.open({
							type: 2,
							title: '导出',
							shadeClose: false,
							shade: 0.5,
							area: ['90%', '90%'],
							content: 'orders_list.html?',
							end: function() {
								location.reload()
							}
						});
					},
					notes_edit: function(id, orderid) {
						console.log(id)
						layer.open({
							type: 2,
							title: '修改备注',
							shadeClose: false,
							shade: 0.5,
							area: ['50%', '50%'],
							content: 'model/order_notes_edit.html?order_id=' + id + '&orderid=' +
								orderid,
							end: function() {
								table.reload()
								//location.reload()
							}
						});
					},
					batchDesignate: function() {
						var checkStatus = table.checkStatus('test-table-operate'),
							data = JSON.stringify(checkStatus.data);
						var id = "";
						for (var i = 0; i < checkStatus.data.length; i++) {
							id += checkStatus.data[i].orderid;
							if (i != checkStatus.data.length - 1) {
								id += ",";
							}
						}
						layer.open({
							type: 2,
							title: '派单',
							shadeClose: false,
							shade: 0.5,
							area: ['90%', '90%'],
							content: 'model/order_designate.html?type=2&orderid=' + id,
							end: function() {
								table.reload()
							}
						});
					},
					batchDelete: function() {
						var checkStatus = table.checkStatus('test-table-operate'),
							data = JSON.stringify(checkStatus.data);
						var id = "";
						for (var i = 0; i < checkStatus.data.length; i++) {
							id += checkStatus.data[i].orderid;
							if (i != checkStatus.data.length - 1) {
								id += ",";
							}
						}
						var lock = false
						layer.confirm('确定要删除所选的' + checkStatus.data.length + '条数据？', function() {
							if (!lock) {
								lock = true
								$.ajax({
									url: server.server_order_delete,
									type: 'post',
									dataType: 'json',
									data: "orderid=" + id,
									success: function(data) {
										if (data.code == '0') {
											layer.msg('操作成功');
											initdata()
										} else {
											layer.msg('操作失败');
										}
									},
									'error': function() {
										layer.msg('系统错误');
									}
								})
							}
						});
					},

				};
				
				//监听提交 原路退
				form.on('submit(formDemo)', function(data){
					if(data.field.refund==2){
						var lock = false
						layer.confirm('确定要取消订单？', function() {
							if (!lock) {
								lock = true
								$.ajax({
									type: "get",
									url:'https://api.aideapi.com/pay/refund',
									data: {
										order_id:cancel_data.orderid,
										amount:cancel_data.pay_price.toFixed(2),
										id:cancel_data.payid
									},
									success: function(res) {
										layer.closeAll()
										let datas=JSON.parse(res)
										if(datas.status=='pending'||datas.status=='success'){
											$.ajax({
												url: server.server_order_cancel,
												type: 'post',
												dataType: 'json',
												data: "orderid=" + cancel_data.orderid,
												success: function(data) {
													if (data.code == '0') {
														layer.closeAll()
														layer.msg('操作成功');
														initdata()
													} else {
														layer.msg('操作失败');
													}
												},
												'error': function() {
													layer.msg('系统错误');
												}
											})
										}else if(datas.status=='failed'){
											cancelOrder()
										}
									}
								});
							}
						});
					}else{
						cancelOrder()
						
					}
				});
				function cancelOrder(){
					var lock = false
					layer.confirm('是否手动退款？', function() {
						if (!lock) {
							lock = true
							$.ajax({
								url: server.server_order_cancel,
								type: 'post',
								dataType: 'json',
								data: "orderid=" + cancel_data.orderid,
								success: function(data) {
									if (data.code == '0') {
										layer.closeAll()
										layer.msg('操作成功');
										initdata()
									} else {
										layer.msg('操作失败');
									}
								},
								'error': function() {
									layer.msg('系统错误');
								}
							})
						}
					});
				}

				$(document).on('click', '.notes', function() {
					var othis = $(this),
						method = othis.data('method');
					active[method] ? active[method].call(this, othis.attr("value"), othis.attr("order")) : '';
				});

				$(document).on('click', '#button', function() {
					var othis = $(this),
						method = othis.data('method');
					active[method] ? active[method].call(this, othis.attr("value")) : '';
				});

				$(document).on('click', '#import_order', function() {
					var othis = $(this),
						method = othis.data('method');
					active[method] ? active[method].call(this, othis.attr("value")) : '';
				});
				$(document).on('click', '#batchDesignate', function() {
					var othis = $(this),
						method = othis.data('method');
					active[method] ? active[method].call(this, othis.attr("value")) : '';
				});
				$(document).on('click', '#batchDelete', function() {
					var othis = $(this),
						method = othis.data('method');
					active[method] ? active[method].call(this, othis.attr("value")) : '';
				});
				//删除
				$('#del').on('click', function() {
					var checkStatus = table.checkStatus('test-table-operate'),
						data = JSON.stringify(checkStatus.data);
					var id = "";
					for (var i = 0; i < checkStatus.data.length; i++) {
						id += checkStatus.data[i].orderid;
						if (i != checkStatus.data.length - 1) {
							id += ",";
						}
					}
					var lock = false
					layer.confirm('确定要删除所选的' + checkStatus.data.length + '条数据？', function() {
						if (!lock) {
							lock = true
							$.ajax({
								url: server.server_order_delete,
								type: 'post',
								dataType: 'json',
								data: "id=" + id,
								success: function(data) {
									if (data.code == '0') {
										layer.msg('删除成功');
										initdata()
									} else {
										layer.msg('删除失败');
									}
								},
								'error': function() {
									layer.msg('系统错误');
								}
							})
						}
					});
				});

				function card_type() {
					statusCheck(-1)
					loading()
					var map = {}
					$.ajax({
						type: "get",
						url: server.querymap,
						async: false,
						success: function(res) {
							if (res.code == 0) {
								map = res.dict_libraries_list.data;
								var data = map.service_order;
								var getTpl = demo_ul.innerHTML,
									view = document.getElementById('view_ul');
								laytpl(getTpl).render(data, function(html) {
									view.innerHTML = html;
								});

							} else {
								layer.msg(res.msg);
							}
						}
					});

					closeloading();
				}

			});
		</script>
	</body>

</html>
